package org.example.Day5;

import java.util.ArrayList;
import java.util.List;

public class ListTest {
    public static void main(){
        List<String> list = new ArrayList<>();
        list.add("蜘蛛精");
        list.add("至尊宝");
        list.add("至尊宝");
        list.add("牛夫人");
        System.out.println(list);

        //在某个位置插入索引
        list.add(2,"紫霞仙子");
        System.out.println(list);

        //根据索引删除 返回删除
        System.out.println(list.remove(2));
        System.out.println(list);

        System.out.println(list.get(3));

        //5.public E set(int index, E e): 修改索引位置处的元素，修改后，会返回原数据
        System.out.println(list.set(3,"⽜魔王")); //⽜夫⼈
        System.out.println(list);
    }
}
